//
//  Player.h
//  TrackingSim
//
//  Created by Garrett Manka on 11/24/11.
//  Copyright (c) 2011. All rights reserved.
//

#ifndef TrackingSim_Player_h
#define TrackingSim_Player_h

#include <string>
#include <math/Vector.h>
#include <math/Quaternion.h>
#include <math/SQT.h>

namespace Sim
{
    class Player
    {
        
    public:
        
        Player();
        Player( const Player& p );
        Player(const std::string& name, Vector pos, Vector vel, Vector up);
        Player(Vector& pos, Vector& vel, Vector& accel, Vector& up);

		virtual ~Player();
        
        virtual unsigned int getPlayerNum() const;
        const std::string& getName() const;
        const std::string& getMesh() const;
        
        virtual const Vector& getPosition() const;
        virtual const Vector& getVelocity() const;
        virtual const Vector& getAcceleration() const;
        virtual const Vector& getUp() const;
        virtual const Vector& getView() const;
        virtual const Vector& getLeft() const;
        virtual const Vector& getAxisColor() const;
        
        virtual const SQT& getSQT() const;
        
        virtual Matrix4x4& getWorldToLocal();
        
        void setMesh(std::string& mesh);
        virtual void setPosition(const Vector& pos);
        virtual void setVelocity(const Vector& vel);
        virtual void setAcceleration(const Vector& accel);
        virtual void setUp(const Vector& up);
        virtual void setView( const Vector& view);
        virtual void setLeft(const Vector& left);
        virtual void setAxisColor(const Vector& color);
        
        //Movement Controls
        
        virtual void stop();
        virtual void resume();
        
        virtual void accelerate();
        virtual void decelerate();
        
        virtual void turnLeft();
        virtual void turnRight();
        
        virtual void rollLeft();
        virtual void rollRight();
        
        virtual void pitchUp();
        virtual void pitchDown();
        
        //Diagnostic functions
        
        virtual void printPos();
        virtual void printVel();
        virtual void printAccel();
        
        
    private:
        
        virtual void rotateYaw(double theta);
        virtual void rotateRoll(double theta);
        virtual void rotatePitch(double theta);
        
    //Attributes
        
    private:
    
        std::string m_name;
        std::string m_mesh;
        unsigned int m_playernum;
        Vector m_velocity;
        Vector m_velocity_previous;
        Vector m_acceleration;
        Vector m_up;
        Vector m_view;
        Vector m_left;
        Vector m_axis_color;
        SQT m_sqt;
        Matrix4x4 m_world_to_local;

        static unsigned int s_playercount;
        const static double s_accel_factor;
        const static double s_turn_rad;
    };
}

#endif
